package com.sparrow.source.controller.third;

import com.alibaba.fastjson.JSONObject;
import com.sparrow.source.common.dto.Result;
import com.sparrow.source.common.dto.UnvDeviceInfo;
import com.sparrow.source.common.dto.UnvPeopleLibraries;
import com.sparrow.source.common.dto.UnvResponse;
import com.sparrow.source.common.enums.ResultEnum;
import com.sparrow.source.persistense.IasUser;
import com.sparrow.source.third.UnvClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author bryceyung
 * @since 2024/11/18
 */
@Controller
@RequestMapping("/unv")
public class UnvController {

    @Autowired
    private UnvClient unvClient;

    @GetMapping("peopleLibraries")
    @ResponseBody
    public UnvPeopleLibraries getPeopleLibraries() {
        return unvClient.getPeopleLibraries(1);
    }

    @GetMapping("deviceInfo")
    @ResponseBody
    public UnvDeviceInfo getDeviceInfo() {
        return unvClient.getDeviceInfo(1);
    }


    @GetMapping("peopleInfo")
    @ResponseBody
    public Boolean getDevicePesonInfo(@RequestParam("deviceId") Integer deviceId){
        return unvClient.getAllPeopleInfo(deviceId);
    }

    @PostMapping("truncate")
    @ResponseBody
    public Result truncatePeople(@RequestParam("deviceId") Integer deviceId){
        JSONObject obj = unvClient.truncatePeopleLibraries(deviceId);
        return Result.build(ResultEnum.SUCCESS).setObject(obj.get("StatusString"));
    }



}
